using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using Utils.Explorer;

namespace MyCollections.Forms
{
    public partial class fFindFolderMovies : Form
    {
        public fFindFolderMovies()
        {
            InitializeComponent();

            this.bt_save_all.Enabled = false;
            this.bt_next.Enabled = false;
            this.bt_previous.Enabled = false;
            this.gb_results.Enabled = false;
        }

        private void cb_result_1_CheckedChanged(object sender, EventArgs e)
        {
            this.bt_find_imdb_1.Visible = !this.cb_result_1.Checked;
        }

        private void cb_result_2_CheckedChanged(object sender, EventArgs e)
        {
            this.bt_find_imdb_2.Visible = !this.cb_result_2.Checked;
        }

        private void cb_result_3_CheckedChanged(object sender, EventArgs e)
        {
            this.bt_find_imdb_3.Visible = !this.cb_result_3.Checked;
        }

        private void cb_result_4_CheckedChanged(object sender, EventArgs e)
        {   
            this.bt_find_imdb_4.Visible = !this.cb_result_4.Checked;
        }

        private void bt_search_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(this.tb_path.Text))
                return;

            bool results = false;

            // Load list of movies
            string[] movies = findFolderMovies(this.tb_path.Text);

            // TODO : find data movie in Imdb

            if (results)
            {
                this.gb_results.Enabled = true;
            }
            else 
            {
                this.gb_results.Enabled = false;
            }
        }

        private void bt_browse_Click(object sender, EventArgs e)
        {
            if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                tb_path.Text = this.folderBrowserDialog1.SelectedPath;
        }

        private string[] findFolderMovies(string path)
        {
            ArrayList completFileList = Tasks.GenerateFileList(path, true);

            // TODO: add file types to config
            ArrayList file_types = new ArrayList();
            file_types.Add(".avi");

            ArrayList selectedFileList = Tasks.FilterFileList(completFileList, file_types);
            ArrayList movies = Files.GetFileNames(selectedFileList);

            return (string[])movies.ToArray(typeof(string));
        }

        private void bt_find_imdb_1_Click(object sender, EventArgs e)
        {

        }

        private void bt_find_imdb_2_Click(object sender, EventArgs e)
        {

        }

        private void bt_find_imdb_3_Click(object sender, EventArgs e)
        {

        }

        private void bt_find_imdb_4_Click(object sender, EventArgs e)
        {

        }
    }
}